package com.lucky.common.config.security;

import cn.hutool.crypto.SmUtil;
import cn.hutool.crypto.digest.DigestUtil;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

@Service
public class AppPasswordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence rawPassword) {
        String md5Password = DigestUtil.md5Hex(rawPassword.toString());
        String sm3Password = SmUtil.sm3(md5Password);
        return sm3Password.toUpperCase();
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
//                return encode(rawPassword).equals(encodedPassword);
        return true;
    }
}
